home *** CD-ROM | disk | FTP | other *** search
- /*==================================================================
- File: ZStringDictionary.h
-
- Contains: Class for parsing named ZStrings into platform-
- specific strings.
-
- Written by: Eric Traut
-
- Copyright: 2000-2001 Connectix Corporation
-
- This source has been placed into the public domain by
- Connectix Corporation. You have the right to modify,
- distribute or use this code without any legal limitations
- or finanicial/licensing requirements. Connectix is not
- liable for any problems that result from the use of this
- code.
-
- If you have comments, feedback, questions, or would like
- to submit bug fixes or updates to this code, please email
- opensource@connectix.com.
- ==================================================================*/
-
- #ifndef __ZSTRINGDICTIONARY__
- #define __ZSTRINGDICTIONARY__
-
- #include "ZStringData.h"
- #include "ZStringParser.h"
- #include "ZString.h"
-
-
- class ZDictionaryEntry
- {
- public:
- // all methods are non-virtual
- ZDictionaryEntry(
- const char * inNameStr,
- Z_UInt16 inNameStrLen,
- Z_Boolean inCopyNameData);
- ~ZDictionaryEntry(void);
-
- ZString mString;
- const char * mNameStr;
- Z_UInt16 mNameStrLen;
- Z_UInt16 mDictionaryOwnsNameData;
- ZDictionaryEntry * mNext;
- };
-
- // The algorithm assumes the hash entry count is a power of two.
- const Z_UInt32 kZDictionaryHashEntries = 1024;
- const Z_UInt32 kZDictionaryEntryMask = (kZDictionaryHashEntries - 1);
-
-
- /*==================================================================
- ZStringDictionary
- ==================================================================*/
-
- class ZStringDictionary
- {
- public:
- // Construction & Destruction
- ZStringDictionary();
-
- virtual
- ~ZStringDictionary();
-
- static ZStringDictionary &
- GetZStringDictionary()
- {
- check(sDictionary != NULL);
- return *sDictionary;
- }
-
- Z_Boolean
- LookUpString(
- const ZStringParseInfo & inParseInfo,
- ZString & outZString);
-
- void
- RegisterString(
- const ZStringParseInfo & inParseInfo,
- ZString & inZString);
-
- static Z_UInt32
- HashString(
- const char * inName,
- Z_UInt16 inNameLen);
-
- private:
- static ZStringDictionary * sDictionary;
- ZDictionaryEntry * mDictionaryHash[kZDictionaryHashEntries];
- };
-
-
-
- #endif // __ZSTRINGDICTIONARY__
-
-